//
//  APLoginPrivacyPolicyController.m
//  AqualPolo
//
//  Created by dong on 2024/5/2.
//

#import "APLoginPrivacyPolicyController.h"
#import "APLoginPrivacyPolicyView.h"
#import "APWebViewController.h"
@interface APLoginPrivacyPolicyController ()<APProtocolControlProtocol>
@property (nonatomic, strong) APLoginPrivacyPolicyView *mainView;
@end

@implementation APLoginPrivacyPolicyController

- (APLoginPrivacyPolicyView *)mainView{
    if (!_mainView) {
        _mainView = [[APLoginPrivacyPolicyView alloc] init];
        _mainView.protocolControl.delegate = self;
        [_mainView.agreeButton addTarget:self action:@selector(agreeButtonDidClick:) forControlEvents:UIControlEventTouchUpInside];
        [_mainView.cancelButton addTarget:self action:@selector(cancelButtonDidClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _mainView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = LYRGBAColor(0, 0, 0, 0.5);
    [self.view addSubview:self.mainView];
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.view);
        make.left.equalTo(self.view).offset(25);
        make.right.equalTo(self.view).offset(-25);
    }];
}

- (void)agreeButtonDidClick:(UIButton *)sender{
    [self dismissViewControllerAnimated:true completion:nil];
    if (self.continueClickCallBack) {
        self.continueClickCallBack();
    }
}

- (void)cancelButtonDidClick:(UIButton *)sender{
    [self dismissViewControllerAnimated:true completion:nil];
}

- (void)termofUseDidClick{
    APWebViewController *webVC = [[APWebViewController alloc] init];
    webVC.urlString = Term_Use__URL;
    webVC.titleString = Term_of_Use_title;
    [self presentViewController:webVC animated:true completion:nil];

}

- (void)privacyPolicyDidClick{
    APWebViewController *webVC = [[APWebViewController alloc] init];
    webVC.urlString = Privacy_Policy_URL;
    webVC.titleString = Privacy_Policy_title;
    [self presentViewController:webVC animated:true completion:nil];
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
        self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    }
    return self;
}

@end
